/**
 * 
 */
package com.miolr.core.jersey;

import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;

import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig.Feature;

import com.miolr.core.jackson.HibernateSerializerFactory;

/**
 * @author iday
 *
 */
@Provider
public class HibernateJacksonContextResolver implements
		ContextResolver<ObjectMapper> {
	private ObjectMapper objectMapper;

	/**
	 * @param objectMapper
	 */
	public HibernateJacksonContextResolver() {
		super();
		this.objectMapper = new ObjectMapper();
		this.objectMapper.setSerializerFactory(HibernateSerializerFactory.instance);
		
		this.objectMapper.configure(Feature.FAIL_ON_EMPTY_BEANS, false);
//		this.objectMapper.configure(Feature.AUTO_DETECT_FIELDS, true);
//		this.objectMapper.setAnnotationIntrospector(new HibernateAnnotationIntrospector());
//		this.objectMapper.registerModule(new HibernateModule());
	}

	@Override
	public ObjectMapper getContext(Class<?> type) {
		return objectMapper;
	}

}
